<template>
  <t-image-viewer v-if="!store.isMobileType" v-model:visible="ImgVisible" :images="[urls + props.info.value]">
  </t-image-viewer>
  <van-image-preview :show-index="false" v-else v-model:show="ImgVisible" :images="[urls + props.info.value]">
  </van-image-preview>
  <div class="outline-parent">
    <img class="outline-parent-bg" :src="publicUrls + 'free/style16/Auxiliaryoutlinestyle1Bg.webp'" alt="" />
    <div class="outline border-hover-style">
      <div
        class="audio-box"
        :class="isPlay && 'audio-rotate'"
        v-if="props.info.audio && props.info.audio.url"
        @click="audioplay(true)"
      ></div>
      <audio v-if="props.info.audio && props.info.audio.url" :src="urls + props.info.audio.url" ref="audioRef"></audio>
      <div
        class="content-item2 content-item6"
        @click="ImgVisible = true"
        v-if="props.info.value && !(props.info.video && props.info.video.url)"
      ></div>
      <div
        class="content-item2 content-item4"
        @click="audioplay(false)"
        v-if="props.info.video && props.info.video.url"
      >
        <videoview :info="props.info"></videoview>
      </div>
      <div
        class="content-item2 content-item5"
        v-if="!props.info.value && !(props.info.video && props.info.video.url)"
      ></div>

      <div
        class="content-box"
        :class="
          !props.info.value &&
          !(props.info.video && props.info.video.url) &&
          !props.info.subTitle &&
          !props.info.remarks &&
          'content-box-show'
        "
      >
        <div class="outline-title">
          {{ props.info.text }}
        </div>
        <p class="outline-subTitle" v-if="props.info.subTitle">——{{ props.info.subTitle }}</p>
        <TextMax
          v-if="props.domShow"
          :data="props.info.remarks"
          :title="props.info.text"
          :infoData="props.info"
          :row="
            props.info.text?.length > 14 && props.info.subTitle
              ? 5
              : props.info.text?.length <= 14 && props.info.subTitle
              ? 6
              : !props.info.subTitle && 7
          "
        ></TextMax>
      </div>
    </div>
    <div class="content-item" v-if="props.info.value || (props.info.video && props.info.video.url)">
      <div class="medium">
        <img
          v-if="props.info.value && !(props.info.video && props.info.video.url)"
          class="outline-cover"
          @click="ImgVisible = true"
          :src="urls + props.info.value + '?imageView2/3/w/898/h/460/format/webp'"
          alt=""
        />
        <videoview @click="audioplay(false)" :info="props.info"></videoview>
      </div>
    </div>
    <div class="content-item content-item3" v-else></div>
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'free16Style1',
});
</script>

<script setup lang="ts">
import { publicUrls } from '@/utils/minxin';
import { useProjectStore } from '@/store';
import { urls } from '@/utils/request/upload';
import { defineComponent, ref } from 'vue';
import TextMax from '@/freeComponents/textMode/TextMax.vue';
import videoview from './../../../videoDialog/videoview.vue';

const props = defineProps({
  info: {
    type: Object,
  },
  domShow: {
    type: Boolean,
  },
});

const ImgVisible = ref(false);
const audioRef = ref(null);
const videoRef = ref(null);
const isPlay = ref(false);
const store = useProjectStore();
const audioplay = (flag: boolean = true) => {
  if (audioRef.value.paused && flag) {
    audioRef.value.play();
    if (videoRef.value) {
      videoRef.value.pause();
    }

    isPlay.value = true;
  } else {
    audioRef.value.pause();
    isPlay.value = false;
  }
};

const videoplay = () => {
  if (videoRef.value.paused) {
    videoRef.value.play();
    if (audioRef.value) {
      audioRef.value.pause();
    }

    isPlay.value = false;
  } else {
    videoRef.value.pause();
    isPlay.value = true;
  }
};
</script>

<style scoped lang="less">
.outline-parent {
  position: relative;
  -webkit-box-reflect: below 220px linear-gradient(transparent, rgba(0, 0, 0, 0.2));
  margin: 0 80px;
}
.outline-parent-bg {
  width: 600px;
  height: 360px;
  margin-top: 50px;
  margin-right: 10px;
}

.outline {
  position: absolute;
  top: 50px;
  left: 0;
  z-index: 20;
  width: 600px;
  height: 360px;
  padding: 30px;
  padding-left: 0;
  display: flex;
  align-items: center;
}
.outline-title {
  width: 100%;
  font-family: 'SourceHanSerifCN-Bold';
  font-size: 20px;
  color: #8a7a6a;
  line-height: 30px;
  text-align: center;
  margin-bottom: 8px;
}
.outline-subTitle {
  width: 100%;
  font-family: SourceHanSerifCN;
  font-size: 16px;
  color: #8a7a6a;
  line-height: 28px;
  text-align: left;
  margin-bottom: 16px;
}
.content-box {
  width: 100%;
  height: 100%;
}
.content-box-show {
  display: flex;
  justify-content: center;
  align-items: center;
}
.content-item2 {
  width: 285px;
  height: 100%;
  flex-shrink: 0;
  ::v-deep .video {
    opacity: 0;
  }
}
.content-item3 {
  background: url(https://static.jiyi.show/free/style16/auxiliary1BG.webp) no-repeat center/100% 100%;
}
.content-item {
  width: 275px;
  height: 359px;
  position: absolute;
  z-index: -1;
  top: 51px;
  left: 0;
}
.medium {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  &:hover .outline-cover {
    transform: scale(1.5);
  }
  ::v-deep .mask-layer {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    position: absolute;
    top: 50%;
    transform: translate(0%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
    .round {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      border: 2px solid rgba(255, 255, 255, 1);
      text-align: center;
      .freeIcon {
        font-size: 24px;
        line-height: 38px;
        color: rgba(255, 255, 255, 1);
      }
    }
  }
  .outline-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    overflow: hidden;
    transition: all 0.3s ease;
  }
}
.audio-rotate {
  animation: audio-rotate 3s linear infinite;
  @keyframes audio-rotate {
    0% {
      transform: rotate(0deg);
    }
    100% {
      transform: rotate(360deg);
    }
  }
}
.audio-box {
  position: absolute;
  bottom: 30px;
  left: 158px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  background: url(https://static.jiyi.show/free/style16/AudioIcon.webp) no-repeat center/100% 100%;
  padding-right: 5px;
  z-index: 1;
  .doorIcon {
    width: 100%;
    height: 100%;
    color: #fff;
    font-size: 26px;
    line-height: 64px;
    text-align: center;
  }
}

::v-deep .textMore-box {
  width: 100%;
  flex: 1;
  // display: flex;
  // align-items: center;
}

::v-deep .van-text-ellipsis {
  color: #333 !important;
  text-align: justify;
  font-family: 'PingFangSC';
  font-size: 16px;
  line-height: 28px !important;
}
::v-deep .van-text-ellipsis__action::before {
  color: #333 !important;
  font-weight: 800 !important;
}
</style>
